package API.ExceptionAPI.CatchError.Logic;

public class IfMultipleError {
    public static int[] arr = {1, 2, 3, 4, 5};

    public static void main(String[] args) {
        throwExceptions();
    }

    public static void throwExceptions() {
        try {
            System.out.println(arr[5]);
            System.out.println(1 / 0);
        //} catch (Exception e) {
        //    System.out.println(e.getMessage());
        //}
        } catch (IndexOutOfBoundsException e) {
            System.out.println(e.getMessage());
        } catch (ArithmeticException e) {
            System.out.println(e.getMessage());
        } // 如果需要抛出国歌异常, 可以依次增加catch, 但是父类异常需要在子类异常下抓取
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
